package com.xiaolin.config;

import net.sf.ezmorph.object.AbstractObjectMorpher;

import java.util.Date;

/**
 * 日期转换类
 */
public class TimestampToDateMorpher extends AbstractObjectMorpher {

    @Override
    public Object morph(Object value) {
        if (value != null) {
            return new Date(Long.parseLong(String.valueOf(value + "000")));
        }
        return null;
    }

    public boolean supports(Class clazz) {
        return Integer.class.isAssignableFrom(clazz);
    }

    @Override
    public Class morphsTo() {
        return Date.class;
    }
}

